<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>功能权限管理</title>
<block th:replace="commonBase"></block>   
</head>
<body>
 
<div class="mini-fit">
	<ul id="tree1" class="mini-tree"  
		 style="width:100%;" showCheckBox = "true" 	 th:attr="url=@{/module/list}" 
			showTreeIcon="true" textField="moduleName" idField="id" expandOnLoad="0"   checkRecursive="true" autoCheckParent="true"
			parentField="parentId" resultAsTree="false" > <!-- allowDrag="true" allowDrop="true"> -->
	</ul>
</div>  
	<div class="mini-toolbar" style="text-align:center;height:25px;padding-top:2px;padding-bottom:8px;" 
        borderStyle="border-left:0;border-bottom:0;border-right:0;">
        <a class="mini-button" onclick="onOk" iconCls="icon-save" style="width:85px;margin-right:20px;">保存</a>
        <span style="display:inline-block;width:25px;"></span>
        <a class="mini-button" onclick="onCancel" iconCls="icon-close" style="width:85px;">关闭</a>
    </div>

</body>

<script th:inline="javascript" type="text/javascript">
 /*<![CDATA[*/

var roleId = "";
var tree = null;//树对象

function setData(data) {
	roleId = data.roleId;//获取角色ID
	mini.parse();
	tree = mini.get("tree1");
	$.ajax({
	        url: basePath+"role/moudles",
			type: 'get',
	        data: {roleId:roleId},
	        cache: false,
	        success: function (successData) {
	        	//alert(successData);
	           tree.setValue(successData,false);
	           // tree.setValue("ajax,json,date,control,forms");
	        	
	        },
	        error: function (XMLHttpRequest, textStatus, errorThrown) {
	        	 mini.unmask(document.body);
	        	 showMsg("查询模块功能错误","danger",800,"center","center",closeWindow);
	        }
	 });
	
}
$(function(){
	
	   	
});


//新增
function onOk(json){
	if(roleId == ""){
		showMsg("请选择要绑定的角色!","warning",1800,"center","center");
		return false;
	}
	var  modules = tree.getValue(true);
	if(!modules){
		showMsg("请选择要绑定的模块!","warning",1800,"center","center");
		return false;
	}
	$.ajax({
        url: basePath+"role/bandlemoudles",
		type: 'post',
        data: {modules:modules,roleId:roleId},
        cache: false,
        success: function (successData) {
        	var message = mini.decode(successData);
        	mini.unmask(document.body);
        	if(message.type == '200'){
            	showMsg("绑定模块成功","success",800,"center","center",closeWindow);
        	}else{
        		showMsg("绑定模块失败","warning",800,"center","center",closeWindow);
        	}
        	
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        	 mini.unmask(document.body);
        	 showMsg("绑定模块错误","danger",800,"center","center",closeWindow);
        }
    });
}
	
	function closeWindow(action) {
	    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
	    else window.close();            
	}
	
	function onCancel(){
		closeWindow("close");
	}


/*]]>*/
</script>
</html>